package com.qf.controller;


import com.qf.service.BookService;
import com.qf.utils.ResultMsg;
import io.swagger.annotations.Api;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "回访接口管理")
@RestController
@RequestMapping("/book")
@CrossOrigin
public class BookController {
    @Autowired
    BookService bookService;

    @GetMapping("/findAll")
    public ResultMsg findAll(@RequestParam(required = false, defaultValue = "1") Integer current, @RequestParam(required = false, defaultValue = "20") Integer pageSize) {
        return bookService.findAll(current, pageSize);
    }

    @GetMapping("/findAll2")
    public ResultMsg findAll2(@RequestParam Map<String, Object> maps) {
        return bookService.findAll2(maps);
    }

    @GetMapping("/findByKeyword")
    public ResultMsg findByKeyword(String keyword) {
        return bookService.findByKeyword(keyword);
    }

    @GetMapping("/sure/{bookId}")
    public ResultMsg sure(@PathVariable Integer bookId) {
        return bookService.sure(bookId);
    }

    @GetMapping("/cancel/{bookId}")
    public ResultMsg cancel(@PathVariable Integer bookId) {
        return bookService.cancel(bookId);
    }

    //查询当天预约
    @GetMapping("/findByDay")
    public ResultMsg findByDay(String time) {
        return bookService.findByDay(time);
    }

    @GetMapping("/findByTomorrow")
    public ResultMsg findByTomorrow() {
        return bookService.findByTomorrow();
    }

    //查询当月预约
    @GetMapping("/findByWeek")
    public ResultMsg findByWeek(String time) {
        return bookService.findByWeek(time);
    }

    //查询当周预约
    @GetMapping("/findByMonth")
    public ResultMsg findByMonth(String time) {
        return bookService.findByMonth(time);
    }

    //查询当周预约
    @PostMapping("/add")
    public ResultMsg add(@RequestBody Map<String, Object> map) {
        return bookService.add(map);
    }


    //删除预约
    @GetMapping("/del/{bookId}")
    public ResultMsg del(@PathVariable Integer bookId) {
        return bookService.del(bookId);
    }


    @GetMapping("/restore/{bookId}")
    public ResultMsg restore(@PathVariable Integer bookId) {
        return bookService.restore(bookId);
    }

    @GetMapping("/delById/{bookId}")
    public ResultMsg delById(@PathVariable Integer bookId) {
        return bookService.delById(bookId);
    }


    @GetMapping("/findByUid/{userId}")
    public ResultMsg findByUid(@PathVariable Integer userId) {
        return bookService.findByUid(userId);
    }

    @GetMapping("/clear")
    public ResultMsg clear() {
        return bookService.clear();
    }
}
